//
//  ZZAudioParameter.m
//  RecorderTest
//
//  Created by 张彦东 on 2017/5/24.
//  Copyright © 2017年 Z. All rights reserved.
//

#import "ZZAudioParameter.h"

@implementation ZZAudioParameter

// 声道数
+ (NSArray *)channels {
    return @[@"单声道", @"双声道"];
}
+ (NSString *)channelsDisplayAtIndex:(NSInteger)index {
    return [self channels][index];
}
+ (NSNumber *)channelsParameterAtIndex:(NSInteger)index {
    return index == 0 ? @1 : @2;
}

// 采样率
+ (NSArray *)sampleRate {
    return @[@"44100Hz", @"48000Hz", @"96000Hz", @"192000Hz"];
}
+ (NSString *)sampleRateDisplayAtIndex:(NSInteger)index {
    return [self sampleRate][index];
}
+ (NSNumber *)sampleRateParameterAtIndex:(NSInteger)index {
    NSNumber *sampleRate;
    switch (index) {
        case 0:
            sampleRate = @44100;
            break;
        case 1:
            sampleRate = @48000;
            break;
        case 2:
            sampleRate = @96000;
            break;
        case 3:
            sampleRate = @192000;
            break;
        default:
            NSLog(@"选择出错");
            sampleRate = @44100;
            break;
    }
    return sampleRate;
}

// 比特率
+ (NSArray *)linearPCMBitDepth {
    return @[@"8bit", @"16bit", @"24bit", @"32bit"];
}
+ (NSString *)linearPCMBitDepthDisplayAtIndex:(NSInteger)index {
    return [self linearPCMBitDepth][index];
}
+ (NSNumber *)linearPCMBitDepthParameterAtIndex:(NSInteger)index {
    NSNumber *linearPCMBitDepth;
    switch (index) {
        case 0:
            linearPCMBitDepth = @8;
            break;
        case 1:
            linearPCMBitDepth = @16;
            break;
        case 2:
            linearPCMBitDepth = @24;
            break;
        case 3:
            linearPCMBitDepth = @32;
            break;
    }
    return linearPCMBitDepth;
}

// 声音音质
+ (NSArray *)audioQuality {
    return @[@"最小", @"比较低", @"中间", @"高", @"最好"];
}
+ (NSString *)audioQualityDisplayAtIndex:(NSInteger)index {
    return [self audioQuality][index];
}
+ (NSNumber *)audioQualityParameterAtIndex:(NSInteger)index {
    NSNumber *audioQuality;
    switch (index) {
        case 0:
            audioQuality = @(AVAudioQualityMin);
            break;
        case 1:
            audioQuality = @(AVAudioQualityLow);
            break;
        case 2:
            audioQuality = @(AVAudioQualityMedium);
            break;
        case 3:
            audioQuality = @(AVAudioQualityHigh);
            break;
        case 4:
            audioQuality = @(AVAudioQualityMax);
            break;
        default:
            NSLog(@"选择出错");
            audioQuality = @(AVAudioQualityMedium);
            break;
    }
    return audioQuality;
}

// 编码比特率 BPS传输速率
+ (NSArray *)encoderBitRate {
    return @[@"默认128000bps"];
}
+ (NSString *)encoderBitRateDisplayAtIndex:(NSInteger)index {
    return [[self encoderBitRate] firstObject];
}
+ (NSNumber *)encoderBitRateParameterAtIndex:(NSInteger)index {
    return @128000;
}

@end
